package com.lefevre.cms.web.action.theme;

import com.lefevre.cms.bean.RequestResult;
import com.lefevre.cms.bean.ResultCode;
import com.lefevre.cms.bean.theme.Themes;
import com.lefevre.cms.service.theme.ThemeService;
import com.lefevre.cms.utils.JsonUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 模板目录显示
 */
@Controller
public class TemplateAction {

    @Resource
    private ThemeService themeService;

    @ResponseBody
    @RequestMapping("/control/template/list")
    public String execute() throws Exception {
        List<Themes> themesList = themeService.findAllTemplates();
        return JsonUtils.toJSONString(new RequestResult(ResultCode.SUCCESS, themesList));
    }
}
